<template>
  <div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td width="10%">设备类型</td>
        <td>
          <el-radio-group v-model="basicForm.basicInfo.type">
            <el-radio :label="0">密封源容器</el-radio>
            <el-radio :label="1">料位计</el-radio>
            <el-radio :label="2">核子秤</el-radio>
            <el-radio :label="3">螺旋管道测量仪</el-radio>
            <el-radio :label="4">测井源</el-radio>
            <el-radio :label="5">测厚仪</el-radio>
            <el-radio :label="6">湿度计</el-radio>
            <el-radio :label="7">密度计</el-radio>
            <el-radio :label="8">
              其他
              <span v-show="basicForm.basicInfo.type === 8">
                (<el-input v-model="basicForm.basicInfo.otherType" type="text" data-cusValidate="text" />)
              </span>
            </el-radio>
          </el-radio-group>
        </td>
      </tr>
      <tr>
        <td width="10%">辐射源种类</td>
        <td style="text-align: left;">
          核素名称:<el-input style="width: 300px" v-model="basicForm.basicInfo.nuclideName" type="text" data-cusValidate="text" />；
          源活度:<el-input style="width: 100px" v-model="basicForm.basicInfo.sourceActivity" />Bq；<br /><br />
          标定日期：
          <el-date-picker
            v-model="basicForm.basicInfo.calibrationDate"
            type="date"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>；
          放射源个数:<el-input style="width: 200px" v-model="basicForm.basicInfo.radioactiveSourceNumber" />；
        </td>
      </tr>
      <tr>
        <td width="10%">标号与编码</td>
        <td style="text-align: left;">
          标号：<el-input style="width: 300px" v-model="basicForm.basicInfo.labelNumber" data-cusValidate="text" />；
          <br /><br />
          编码：<el-input style="width: 300px" v-model="basicForm.basicInfo.coding" data-cusValidate="text" />；
        </td>
      </tr>
      <tr>
        <td>检测仪表使用场所</td>
        <td>
          <el-select
            style="width: 100%;"
            v-model="basicForm.basicInfo.placeType"
            placeholder="请选择"
            @change="handlePlaceTypeChange"
          >
            <el-option
              v-for="(dict, index) in dict.type.sealed_source_place_type"
              :key="index"
              :value="Number(dict.value)"
              :label="dict.label"
            ></el-option>
          </el-select>
        </td>
      </tr>
      <tr>
        <td width="10%">备注</td>
        <td>
          <el-input v-model="basicForm.basicInfo.remark" type="text" data-cusValidate="text" />
        </td>
      </tr>
    </table>

    <div class="equipmenttitle">
      放射源信息
    </div>
    <table style="width: 100%" border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td style="width: 50px;">序号</td>
        <td style="width: 150px;">核素名称</td>
        <td style="width: 100px;">出厂日期</td>
        <td style="width: 150px;">出场活度(Bq)</td>
        <td>标号</td>
        <td>编码</td>
        <td>用途</td>
        <td style="width: 50px;"></td>
      </tr>
      <tr v-for="(item, index) in basicForm.basicInfo.nuclideInfoList || []">
        <td>{{ index + 1 }}</td>
        <td>
          <el-select v-model="item.nuclideName" placeholder="请选择">
            <el-option
              v-for="(dict, index) in dict.type.nuclide_type"
              :key="index"
              :value="dict.value"
              :label="dict.label"
            ></el-option>
          </el-select>
        </td>
        <td>
          <el-date-picker
            style="height: 32px;"
            v-model="item.calibrationDate"
            type="date"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </td>
        <td>
          <el-input style="height: 32px;" v-model="item.sourceActivity" type="text" data-cusValidate="text" />
        </td>
        <td>
          <el-input style="height: 32px;" v-model="item.labelNumber" type="text" data-cusValidate="text" />
        </td>
        <td>
          <el-input style="height: 32px;" v-model="item.coding" type="text" data-cusValidate="text" />
        </td>
        <td>
          <el-input style="height: 32px;" v-model="item.purpose" type="text" data-cusValidate="text" />
        </td>
        <td>
          <span
            style="
              display: inline-block;
              width: 50px;
              padding: 2px 0;
              border: 1px solid #ccc;
              color: #888;
              border-radius: 2px;
              cursor: pointer;
              position: relative;
              z-index: 999;
            "
            @click="handleRemoveNuclideInfoRow(index)"
            >-</span
          >
        </td>
      </tr>
      <tr>
        <td colspan="8">
          <span
            style="
              display: inline-block;
              width: 50px;
              padding: 2px 0;
              border: 1px solid #ccc;
              margin-left: 10px;
              color: #888;
              border-radius: 2px;
              cursor: pointer;
              position: relative;
              z-index: 999;
            "
            @click="handleAddNuclideInfoRow"
            >+</span
          >
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
  export default{
    name:'basicTable71',
    dicts: ['sealed_source_place_type', 'nuclide_type'],
    data(){
      return{

      }
    },
    props: {
    	// 基本信息数据
      basicForm: {
    		type: Object,
        default: () => {
    			return {}
    		},
      },
    	// 状态
      lrstatus: {
    		type: String,
        default: "",
      },
    },
    methods: {
      handleAddNuclideInfoRow() {
        if (!this.basicForm.basicInfo.nuclideInfoList) {
          this.basicForm.basicInfo.nuclideInfoList = [];
        }
        this.basicForm.basicInfo.nuclideInfoList.push({
          nuclideName: '',
          calibrationDate: '',
          sourceActivity: '',
          labelNumber: '',
          coding: '',
          purpose: '',
        });
      },
      handleRemoveNuclideInfoRow(index) {
        this.basicForm.basicInfo.nuclideInfoList.splice(index, 1);
      },
      handlePlaceTypeChange(value) {
        const findRes = this.dict.type.sealed_source_place_type.find(item => {
          return item.value == value
        });
        if (!findRes) return
        this.basicForm.basicInfo.remark = findRes.label
        this.basicForm.specialCircumstances = findRes.label
      }
    }
  }
</script>

<style lang="scss" scoped>
  @import '../content.scss';

  ::v-deep .el-select > .el-input {
    height: 36px;
  }
</style>
